package by.grsu.crs.form;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class SignUpStepTwoForm extends ActionForm {
	private static final long serialVersionUID = 703679257407690432L;
	
	private String passportNumber;
	private String creditCard;
	private String name;
	private String surname;
	private String patronymic;
	private String birthdate;
	private String phone;
	private String country;
	private String zip;
	private String state;
	private String city;
	private String street;
	private String house;
	private String apartment;
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        
        if (name == null || name.length() < 1) {
            errors.add("name", new ActionMessage("error.name.required"));
        }
        
        if (surname == null || surname.length() < 1) {
            errors.add("surname", new ActionMessage("error.surname.required"));
        }

        if (patronymic == null || patronymic.length() < 1) {
            errors.add("patronymic", new ActionMessage("error.patronymic.required"));
        }
        
        if (passportNumber == null || passportNumber.length() < 1) {
            errors.add("passportNumber", new ActionMessage("error.passportNumber.required"));
        }
        
        if (creditCard == null || creditCard.length() < 1) {
            errors.add("creditCard", new ActionMessage("error.creditCard.required"));
        }
        
        if (birthdate == null || birthdate.length() < 1) {
            errors.add("birthdate", new ActionMessage("error.birthdate.required"));
        }
        
        if (phone == null || phone.length() < 1) {
            errors.add("phone", new ActionMessage("error.phone.required"));
        }
        
        if (country == null || country.length() < 1) {
            errors.add("country", new ActionMessage("error.country.required"));
        }
        
        if (zip == null || zip.length() < 1) {
            errors.add("zip", new ActionMessage("error.zip.required"));
        }
        
        if (state == null || state.length() < 1) {
            errors.add("state", new ActionMessage("error.state.required"));
        }
        
        if (city == null || city.length() < 1) {
            errors.add("city", new ActionMessage("error.city.required"));
        }
        
        if (street == null || street.length() < 1) {
            errors.add("street", new ActionMessage("error.street.required"));
        }
        
        if (house == null || house.length() < 1) {
            errors.add("house", new ActionMessage("error.house.required"));
        }
        
        if (apartment == null || apartment.length() < 1) {
            errors.add("apartment", new ActionMessage("error.apartment.required"));
        }
        
        return errors;
	}

	public String getPassportNumber() {
		return passportNumber;
	}

	public void setPassportNumber(String passportNumber) {
		this.passportNumber = passportNumber;
	}

	public String getCreditCard() {
		return creditCard;
	}

	public void setCreditCard(String creditCard) {
		this.creditCard = creditCard;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public String getPatronymic() {
		return patronymic;
	}

	public void setPatronymic(String patronymic) {
		this.patronymic = patronymic;
	}

	public String getBirthdate() {
		return birthdate;
	}
	
	public Date getBirthdateDate() {
		return (Date) java.sql.Date.valueOf(this.birthdate);
	}

	public void setBirthdate(String birthdate) {
		this.birthdate = birthdate;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getHouse() {
		return house;
	}

	public void setHouse(String house) {
		this.house = house;
	}

	public String getApartment() {
		return apartment;
	}

	public void setApartment(String apartment) {
		this.apartment = apartment;
	}
}
